import { findBanner, findCategory1, findListGoods, findRecommendGoods } from '../../api/home'

Page({
  data: {
    bannerList: [], // 轮播图
    navList: [], // 导航列表
    listGoods: [], // 商品列表
    recommendGoods: [], // 人气推荐
  },
  onLoad() {
    this.getBanner();
    this.getCategory1();
    this.getListGoods();
    this.getRecommenddGoods();
  },
  async getBanner() {
    try {
      let result = await findBanner()
      this.setData({
        bannerList: result.data
      })
    } catch (error) {
      console.log(error);
    }
  },
  async getCategory1(){
    try {
      let result = await findCategory1();
      this.setData({
        navList: result.data
      })
    } catch (error) {
      console.log(error);
    }
  },
  async getListGoods(){
    try {
      let result = await findListGoods();
      this.setData({
        listGoods: result.data
      })
    } catch (error) {
      console.log(error);
    }
  },
  async getRecommenddGoods(){
    try {
      let result = await findRecommendGoods();
      this.setData({
        recommendGoods: result.data
      })
    } catch (error) {
      console.log(error);
    }
  }
})
